import java.util.Scanner;

public class LanQiaoPractice1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int ret = 0;
        int q = 5;
        while (q-- > 0){
            char[] ss = in.next().toCharArray();
            if(ss[0] == ss[2] && ss[3] - ss[1] == 1){
                ret++;
            }
        }
        System.out.println(ret);
    }
}
